/**
 * [66] 加一
 *
 * @format
 * @lc app=leetcode.cn id=66 lang=javascript
 */

// @lc code=start
/**
 * @param {number[]} digits
 * @return {number[]}
 */
var plusOne = function (digits) {
    let carry = 1
    let result = ""
    for (let i = digits.length - 1; i >= 0; i--) {
        result = ((digits[i] + carry) % 10) + result
        carry = Math.floor((digits[i] + carry) / 10)
    }
    carry > 0 ? (result = carry + result) : null
    return result.split("")
}
// @lc code=end
